package net.oschina.app.ui;

import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.RelativeLayout;
import android.widget.TextView;

import net.oschina.app.R;
import net.oschina.app.base.BaseActivity;
import net.oschina.app.ui.view.SettingItemView;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * 设置界面的Activity
 */
public class SettingActivity extends BaseActivity {
    @BindView(R.id.siv_load_image)
    SettingItemView mSivLoadImage;
    @BindView(R.id.tv_alerts)
    TextView        mTvAlerts;
    @BindView(R.id.tv_clear)
    TextView        mTvClear;
    @BindView(R.id.tv_cache)
    TextView        mTvCache;
    @BindView(R.id.rl_clear)
    RelativeLayout  mRlClear;
    @BindView(R.id.tv_double_click)
    SettingItemView mTvDoubleClick;
    @BindView(R.id.tv_china)
    TextView        mTvChina;
    @BindView(R.id.tv_exit)
    TextView        mTvExit;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_setting);
        ButterKnife.bind(this);
    }

    @OnClick({R.id.siv_load_image, R.id.tv_alerts, R.id.tv_clear, R.id.rl_clear, R.id.tv_double_click, R.id.tv_china, R.id.tv_exit})
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.siv_load_image: //加载图片
                break;
            case R.id.tv_alerts: //消息通知
                Intent intent = new Intent(this,NesRemind.class);
                startActivity(intent);
                break;
            case R.id.tv_clear:  //清理缓存控件
                showCacheDialog();
                break;
//            case R.id.rl_clear: //清理缓存布局
//                break;
            case R.id.tv_double_click: //双击退出
                break;
            case R.id.tv_china:  //开源中中国
                break;
            case R.id.tv_exit:   //退出
                showExitChinaDialog();
                break;
        }
    }

    //显示退出开源中国对话框
    private void showExitChinaDialog() {
        AlertDialog.Builder builder = new AlertDialog.Builder(this)
                .setIcon(R.drawable.woman)
                .setTitle("退出开源中国")
                .setMessage("退出后将不再收到新的消息提醒")
               /* .setNegativeButton("取消", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialogInterface, int i) {
                        // TODO:
                    }
                })
                .setPositiveButton("确定", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialogInterface, int i) {
                        // TODO:
                    }
                })*/
        ;
        builder.show();
    }

    //显示是否清除缓存对话框
    private void showCacheDialog() {
        AlertDialog.Builder builder = new AlertDialog.Builder(this)
        .setMessage("是否清空缓存")
        .setNegativeButton("取消", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialogInterface, int i) {
                // TODO:
            }
        })
        .setPositiveButton("确定", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialogInterface, int i) {
                // TODO:
            }
        });
        builder.show();
    }
}
